package org.xmls.common.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 时间间隔的枚举
 */
@Getter
@AllArgsConstructor
public enum DateIntervalEnum {

    DAY(1, "天"),
    WEEK(2, "周"),
    MONTH(3, "月"),
    QUARTER(4, "季度"),
    YEAR(5, "年")
    ;


    /**
     * 类型
     */
    private final Integer interval;
    /**
     * 名称
     */
    private final String name;

    public static DateIntervalEnum getByInterval(Integer interval) {
        return Arrays.stream(values()).filter(item -> item.getInterval().equals(interval)).findFirst().orElse(null);
    }

}